#from testApp import *
import utils
from RickTree import RickTree

utils.printTime("Deserialize matrix2")
matrix2 = utils.load('matrix2.ser')
utils.printTime("Deserialize allwords")
allwords = utils.load('allwords.ser')

t = RickTree(allwords,matrix2)

t.createDomain()
t.saveDomain()
#t.loadDomain()

t.createData()
t.saveData()
#t.loadData()

t.createTree()
t.saveTree()
#t.loadTree()

#t.classifyLearningData()

#t.createDataTest()
#t.saveDataTest()
#t.loadDataTest()

#t.classifyTestingData()

import learning
import utils as u
cats = u.load('categories.ser')
cls = u.load('cls.ser')

cat, words = learning.getWords('../../Part1/awards_1994/awd_1994_00', 'a9400001.txt')
res = t.classify(words)
catID = cats.bag[cat][0]
clsID = cls.cat2clus[catID]
print res,'VS',clsID
'''
cat, words = learning.getWords('../../Part1/awards_1994/awd_1994_00', 'a9400011.txt')
res = t.classify(words)
catID = cats.bag[cat][0]
clsID = cls.cat2clus[catID]
print res,'VS',clsID

cat, words = learning.getWords('../../Part1/awards_1994/awd_1994_00', 'a9400019.txt')
res = t.classify(words)
catID = cats.bag[cat][0]
clsID = cls.cat2clus[catID]
print res,'VS',clsID

cat, words = learning.getWords('../../Part1/awards_1994/awd_1994_00', 'a9400023.txt')
res = t.classify(words)
catID = cats.bag[cat][0]
clsID = cls.cat2clus[catID]
print res,'VS',clsID

cat, words = learning.getWords('../../Part1/awards_1994/awd_1994_00', 'a9400024.txt')
res = t.classify(words)
catID = cats.bag[cat][0]
clsID = cls.cat2clus[catID]
print res,'VS',clsID
'''
